/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thread.demo.newpackage;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author VANDH
 */
public class Radio extends Thread {

    public static int count = 0;

    @Override
    public void run() {
        synchronized (Radio.class) {
            System.out.println(this.getName() + " - I'm running here..." + ++count);
            try {
                Thread.sleep(5000);
                if (count == 1) {
                    Radio.class.wait();
                } else {
                    Radio.class.notify();
                }
                System.out.println(this.getName() + "- Awaken -" + count);
            } catch (InterruptedException ex) {
                System.out.println(ex.getMessage());
            }
        }
    }
}
